from flask import Flask
from flask import make_response
from flask import request

app = Flask(__name__)

@app.route("/set")
def set_cookies():
    # 获取对象
    response = make_response("Responser set cookies success !")
    # 设置值
    response.set_cookie("name","Python Flask")
    response.set_cookie("edu118","XYD")
    # 设置超时时间:1小时过期
    response.set_cookie("userid","u7709",max_age=3600)
    return response

@app.route("/get")
def get_cookie():
    # 获取值
    xydname = request.cookies.get("edu118")
    name = request.cookies.get("name")
    userid = request.cookies.get("userid")
    content = "<h1>name值:%s</h1><h2>edu118值:%s</h2><h3>userid值:%s</h3>"%(name,xydname,userid)
    return content

@app.route("/delete")
def delete_cookie():
    resp = make_response("Get cookie success.")
    # 删除cookie
    resp.delete_cookie("name")
    return resp

if __name__ == '__main__':
    app.run()